#pragma once

struct IpcBlock
{
	void* buffer;
	UINT bufsize;
};

class IpcChannel
{
public:
	IpcChannel();
	virtual ~IpcChannel();

	bool createMaster(PCTSTR name);
	bool createSlave(PCTSTR name);
	void destroy();

	bool lock();
	bool write(void* buf, UINT bufsize);
	bool read(UINT& blockcount, IpcBlock block[]);
	bool unlock();
private:
	HANDLE _mmaphandle;
	HANDLE _mutex;
};
